package com.wicket.okrcomponent.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.wicket.okrcomponent.biz.service.dto.req.*;
import com.wicket.okrcomponent.biz.service.dto.res.*;
import com.wicket.okrcomponent.common.exception.BizException;
import com.wicket.okrcomponent.common.util.CommonFunctionHelper;
import com.wicket.okrcomponent.common.util.RedisUtil;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.wicket.okrcomponent.common.exception.Assert;
import com.wicket.okrcomponent.biz.service.nb.NbCommon;
import cn.hutool.core.collection.CollectionUtil;
import com.wicket.okrcomponent.biz.service.StatisticalDataService;
import com.wicket.okrcomponent.biz.service.InterfaceModeService;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@Service
public class CommonServiceImpl
  implements com.wicket.okrcomponent.biz.service.CommonService {

  @Resource
  private RedisUtil redisUtil;
//@Resource
 //private MCustomFieldsService mCustomFieldsService;
@Resource
  private NbCommon nbCommon;
//@Resource
 //private MCustomFields5Service mCustomFields5Service;
@Resource
  private StatisticalDataService statisticalDataService;
@Resource
  private InterfaceModeService interfaceModeService;
/**
   * D2删除物理文件(公共)[2913]
   * gen by moon at 4/5/2024, 8:48:19 PM
   */
  @Trace(operationName = "D2删除物理文件(公共)")
  @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Transactional(rollbackFor=Exception.class)
  @Override
  public DeleteFileComRespDto deleteFileCom(DeleteFileComReqDto reqDto){
    
      
      //步骤0: M2删除附件(特殊方法） - deleteFile
     //ModelCode: deleteFile
        DeleteFileRespDto deleteFileRes = null;
    DeleteFileReqDto deleteFileReq=new DeleteFileReqDto();
  if(reqDto!=null){
      deleteFileReq.setMediaContentAddress(reqDto.getMediaContentAddress());//SimpleFieldAssign//sourceId:1135501_1
deleteFileReq.setFileStorageRootPath(reqDto.getFileStorageRootPath());//SimpleFieldAssign//sourceId:1139427_1
    }
  
    /*M2删除附件(特殊方法）[2912]   */
    Assert.isNull(deleteFileReq.getMediaContentAddress(),"D2删除物理文件(公共)-M2删除附件(特殊方法）-媒体内容地址不能为空",false);
Assert.isNull(deleteFileReq.getFileStorageRootPath(),"D2删除物理文件(公共)-M2删除附件(特殊方法）-文件存储根路径不能为空",false);
      deleteFileRes = nbCommon.deleteFile(deleteFileReq);
      
      
      
    
DeleteFileComRespDto retData = new DeleteFileComRespDto();
  
  

  
  
return retData;
  }
/**
   * D2计算排序(公共)[10026]
   * gen by moon at 7/23/2024, 8:51:08 PM
   */
  @Trace(operationName = "D2计算排序(公共)")
  @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Transactional(rollbackFor=Exception.class)
  @Override
  public CalculateSortNumComRespDto calculateSortNumCom(CalculateSortNumComReqDto reqDto){


      ImplementTenReceivingFieldRespDto receptionServiceRes_1 =null;
//步骤0: D2统计数据集内容条数服务(公共) - calculateContentAmountCom
     CalculateContentAmountComRespDto calculateContentAmountComRespDto = null;
    CalculateContentAmountComReqDto calculateContentAmountComReqDto=new CalculateContentAmountComReqDto();
  if(reqDto!=null){
      calculateContentAmountComReqDto.setContentAmountList(reqDto.getContentAmountList());//list-field-assign//sourceId:1949193_1
    }

    /*D2统计数据集内容条数服务(公共)[3386]   */

      calculateContentAmountComRespDto = statisticalDataService.calculateContentAmountCom(calculateContentAmountComReqDto)/*vcase invoke isSameApp*/;




//步骤1: D2-计算两个数值相加(公共) - calculateAdditionOfTwoNumsCom
     CalculateAdditionOfTwoNumsComRespDto calculateAdditionOfTwoNumsComRespDto = null;
    if(calculateContentAmountComRespDto !=null){
          CalculateAdditionOfTwoNumsComReqDto calculateAdditionOfTwoNumsComReqDto=new CalculateAdditionOfTwoNumsComReqDto();
  calculateAdditionOfTwoNumsComReqDto.setCalcPara2(Double.valueOf("1"));//CUSTOM_CONVENTION//sourceId:1949196_1
if(calculateContentAmountComRespDto!=null){
      calculateAdditionOfTwoNumsComReqDto.setCalcPara1(calculateContentAmountComRespDto.getCalcCount()!=null?Double.valueOf(calculateContentAmountComRespDto.getCalcCount()):null);//SimpleFieldAssign//sourceId:1949195_1
    }

    /*D2-计算两个数值相加(公共)[8137]   */
    Assert.isNull(calculateAdditionOfTwoNumsComReqDto.getCalcPara1(),"D2计算排序(公共)-D2-计算两个数值相加(公共)-计算入参1不能为空",false);
Assert.isNull(calculateAdditionOfTwoNumsComReqDto.getCalcPara2(),"D2计算排序(公共)-D2-计算两个数值相加(公共)-计算入参2不能为空",false);
      calculateAdditionOfTwoNumsComRespDto = interfaceModeService.calculateAdditionOfTwoNumsCom(calculateAdditionOfTwoNumsComReqDto)/*vcase invoke isSameApp*/;



           }

//步骤2: M2执行第十接收字段（特殊方法） - implementTenReceivingField
     //ModelCode: receptionService
        ImplementTenReceivingFieldRespDto receptionServiceRes = null;
    if(calculateAdditionOfTwoNumsComRespDto !=null){
          ImplementTenReceivingFieldReqDto receptionServiceReq=new ImplementTenReceivingFieldReqDto();
  if(calculateAdditionOfTwoNumsComRespDto!=null){
      receptionServiceReq.setOrderNumber(calculateAdditionOfTwoNumsComRespDto.getCalcResult()!=null?calculateAdditionOfTwoNumsComRespDto.getCalcResult().longValue():null);//SimpleFieldAssign//sourceId:1949439_1
    }

    /*M2接收排序值出参[8782]  用于特殊方法接收上游入参。 */
    Assert.isNull(receptionServiceReq.getOrderNumber(),"D2计算排序(公共)-M2接收排序值出参-排序不能为空",false);
      receptionServiceRes = nbCommon.implementTenReceivingField(receptionServiceReq);


      receptionServiceRes_1 = receptionServiceRes;
           }

CalculateSortNumComRespDto retData = new CalculateSortNumComRespDto();
  if(receptionServiceRes_1!=null){
      retData.setOrderNumber(receptionServiceRes_1.getOrderNumber());//SimpleFieldAssign//sourceId:1949442_1
    }




return retData;
  }
/**
   * D2分析树层级标识(公共)[10028]
   * gen by moon at 7/24/2024, 2:43:41 AM
   */
  @Trace(operationName = "D2分析树层级标识(公共)")
  @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Transactional(rollbackFor=Exception.class)
  @Override
  public AnalysisLevelCodeComRespDto analysisLevelCodeCom(AnalysisLevelCodeComReqDto reqDto){


      AnalysisLevelCodeRespDto getCurrentContentCodeRes_1 =null;
//步骤0: M2分析层级标识（特殊方法） - analysisLevelCode
     //ModelCode: getCurrentContentCode
        AnalysisLevelCodeRespDto getCurrentContentCodeRes = null;
    AnalysisLevelCodeReqDto getCurrentContentCodeReq=new AnalysisLevelCodeReqDto();
  if(reqDto!=null){
      getCurrentContentCodeReq.setSuperiorContentCode(reqDto.getSuperiorContentCode());//SimpleFieldAssign//sourceId:1949448_1
getCurrentContentCodeReq.setSiblingCodeList(reqDto.getSiblingCodeList());//list-field-assign//sourceId:1949449_1
    }

    /*M2分析层级标识（特殊方法）[10029]  用于新建内容时，获取当前层级内容标识。如新增空间、新增指标。入参上级标识CODE，当前层级所有标识CODE，获取本次新增内容的标识CODE */
    Assert.isNull(getCurrentContentCodeReq.getSuperiorContentCode(),"D2分析树层级标识(公共)-M2分析层级标识（特殊方法）-上级内容标识不能为空",false);
      getCurrentContentCodeRes = nbCommon.analysisLevelCode(getCurrentContentCodeReq);


      getCurrentContentCodeRes_1 = getCurrentContentCodeRes;

AnalysisLevelCodeComRespDto retData = new AnalysisLevelCodeComRespDto();
  if(getCurrentContentCodeRes_1!=null){
      retData.setCurrentContentCode(getCurrentContentCodeRes_1.getCurrentContentCode());//SimpleFieldAssign//sourceId:1949453_1
    }




return retData;
  }
  //
}
